package com.mk.service;

import act.job.Cron;
import cn.hutool.core.date.DateUtil;
import com.mk.domain.CpTaskLog;
import com.mk.util.S2;

import javax.inject.Inject;

/**
 * 所有定时i任务
 */
@SuppressWarnings("all")
public class TimeTaskService {
    @Inject
    private CpTaskLog.Mapper cpTaskLogMapper;

    private void insertCpTaskLog(String taskname, String taskmethod, String time) {
        CpTaskLog log = new CpTaskLog();
        log.setId(S2.UUID());
        log.setCreatetime(DateUtil.now());
        log.setTaskmethod(taskmethod);
        log.setTasktime(time);
        log.setTaskname(taskname);
        cpTaskLogMapper.insert(log);
    }

    //每天过了0点执行一次定时
//    @Every("300s")
    @Cron("1 0 0 * * ?")
    public void updateShopLevel() {
        insertCpTaskLog("每天过了0点执行一次定时", "updateShopLevel", "@Cron(\"1 0 0 * * ?\")");
    }


}
